package com.example.medicine.Mapper;


import com.example.medicine.Bean.yian.yian;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface gujiMapper {
    @Select("select * from [yian] where fenlei='古籍' ORDER BY createtime DESC")
    List<yian> getAll();

    @Select("select * from [yian] where id=#{id}")
    public yian getById(long id);
    @Select("select * from [yian] where createuser=#{createuser} and fenlei='古籍'")
    public List<yian> getByUser(String createuser);
    @Insert("INSERT INTO yian(fengmian, dimian, biaohao, xingming, jiuzhenyisheng, jiuzhenleixin, keshi, " +
            "xingbie, hunkuang, yaowoguominshi, year, month, day, otherTime, nianling, fabingjieqi, chaodai, " +
            "shuming,isbn, yema, yemaEnd, banci, chubanshijian, zuozhe, chubanshe,zhangjie,tiaowenxuhao,yuanwen, zhushu, xianbingshi,shezhen, jzs, jws, " +
            "hanre, hanzhen, xingti, shenzhi, yinshi, yinshui, xiaobian, dabian, shuimian, yuyan, toumian, toubu, " +
            "ermu, koubiyan, jingxiang, xiongfu, yaobei, sizhi, yuejing, baidai, sysjc, zhize, zhifa, shuoming, " +
            "qtyz, bafx, xxxd, chufangmingcheng, leixing, jixing, jianfufa, fuyaoshijian, jishu, shiyongfangfa, " +
            "cishuyaoliang, fuhoufankui, qitashixiang, jinguzhi,createuser,createtime,fenlei,shenhe,fangFaoyuanwen) " +
            "VALUES(#{fengmian}, #{dimian}, #{biaohao}, #{xingming}, #{jiuzhenyisheng}, #{jiuzhenleixin}, #{keshi}, " +
            "#{xingbie}, #{hunkuang}, #{yaowoguominshi}, #{year}, #{month}, #{day}, #{otherTime}, #{nianling}, " +
            "#{fabingjieqi}, #{chaodai}, #{shuming},#{isbn}, #{yema}, #{yemaEnd}, #{banci}, #{chubanshijian}, #{zuozhe}, " +
            "#{chubanshe},#{zhangjie},#{tiaowenxuhao},#{yuanwen}, #{zhushu}, #{xianbingshi},#{shezhen}, #{jzs}, #{jws}, #{hanre}, #{hanzhen}, #{xingti}, #{shenzhi}, " +
            "#{yinshi}, #{yinshui}, #{xiaobian}, #{dabian}, #{shuimian}, #{yuyan}, #{toumian}, #{toubu}, #{ermu}, " +
            "#{koubiyan}, #{jingxiang}, #{xiongfu}, #{yaobei}, #{sizhi}, #{yuejing}, #{baidai}, #{sysjc}, #{zhize}, " +
            "#{zhifa}, #{shuoming}, #{qtyz}, #{bafx}, #{xxxd}, #{chufangmingcheng}, #{leixing}, #{jixing}, #{jianfufa}, " +
            "#{fuyaoshijian}, #{jishu}, #{shiyongfangfa}, #{cishuyaoliang}, #{fuhoufankui}, #{qitashixiang}, #{jinguzhi},#{createuser},getdate(),'古籍',#{shenhe},#{fangFaoyuanwen})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    public void insert(yian yian);

    @Insert({
            "<script>",
            "INSERT INTO yian( biaohao, xingming, jiuzhenyisheng, jiuzhenleixin, keshi, " +
                    "xingbie, hunkuang, yaowoguominshi, year, month, day, otherTime, nianling, fabingjieqi, chaodai, " +
                    "shuming, yema, yemaEnd, banci, chubanshijian, zuozhe, chubanshe, zhushu, jzs,jws,xianbingshi,xxxd,fenlei," +
                    "zhangjie,tiaowenxuhao,yuanwen,createuser,createtime,shenhe) VALUES ",
            "<foreach collection='yians' item='yian' separator=','>",
            "( #{yian.biaohao}, #{yian.xingming}, #{yian.jiuzhenyisheng}, #{yian.jiuzhenleixin}, #{yian.keshi}, " +
                    "#{yian.xingbie}, #{yian.hunkuang}, #{yian.yaowoguominshi}, #{yian.year}, #{yian.month}, #{yian.day}, #{yian.otherTime}, #{yian.nianling}, " +
                    "#{yian.fabingjieqi}, #{yian.chaodai}, #{yian.shuming}, #{yian.yema}, #{yian.yemaEnd}, #{yian.banci}, #{yian.chubanshijian}, #{yian.zuozhe}, " +
                    "#{yian.chubanshe}, #{yian.zhushu},#{yian.jzs}, #{yian.jws}, #{yian.xianbingshi},#{yian.xxxd},'古籍'," +
                    "#{yian.zhangjie},#{yian.tiaowenxuhao},#{yian.yuanwen},#{yian.createuser},getdate(),#{yian.shenhe})",
            "</foreach>",
            "</script>"
    })
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void batchInsert(@Param("yians") List<yian> yians);

    @Update("UPDATE [yian] SET  xingming = #{xingming}, jiuzhenyisheng = #{jiuzhenyisheng}, jiuzhenleixin = #{jiuzhenleixin}, " +
            "keshi = #{keshi}, xingbie = #{xingbie}, hunkuang = #{hunkuang}, yaowoguominshi = #{yaowoguominshi}, year = #{year}, month = #{month}, day = #{day}, " +
            "otherTime = #{otherTime}, nianling = #{nianling}, fabingjieqi = #{fabingjieqi}, chaodai = #{chaodai}, shuming = #{shuming}, yema = #{yema}, yemaEnd = #{yemaEnd}, " +
            "banci = #{banci}, chubanshijian = #{chubanshijian}, zuozhe = #{zuozhe}, chubanshe = #{chubanshe},zhangjie=#{zhangjie},tiaowenxuhao=#{tiaowenxuhao},yuanwen=#{yuanwen}, zhushu = #{zhushu}, xianbingshi = #{xianbingshi},shezhen=#{shezhen}, jzs = #{jzs}, " +
            "jws = #{jws}, hanre = #{hanre}, hanzhen = #{hanzhen}, xingti = #{xingti}, shenzhi = #{shenzhi}, yinshi = #{yinshi}, yinshui = #{yinshui}, xiaobian = #{xiaobian}, " +
            "dabian = #{dabian}, shuimian = #{shuimian}, yuyan = #{yuyan}, toumian = #{toumian}, toubu = #{toubu}, ermu = #{ermu}, koubiyan = #{koubiyan}, jingxiang = #{jingxiang}, " +
            "xiongfu = #{xiongfu}, yaobei = #{yaobei}, sizhi = #{sizhi}, yuejing = #{yuejing}, baidai = #{baidai}, sysjc = #{sysjc}, zhize = #{zhize}, zhifa = #{zhifa}, " +
            "shuoming = #{shuoming}, qtyz = #{qtyz}, bafx = #{bafx}, xxxd = #{xxxd}, chufangmingcheng = #{chufangmingcheng}, leixing = #{leixing}, jixing = #{jixing}, " +
            "jianfufa = #{jianfufa}, fuyaoshijian = #{fuyaoshijian}, jishu = #{jishu}, shiyongfangfa = #{shiyongfangfa}, cishuyaoliang = #{cishuyaoliang}, fuhoufankui = #{fuhoufankui}, " +
            "qitashixiang = #{qitashixiang}, jinguzhi = #{jinguzhi}, fangFaoyuanwen = #{fangFaoyuanwen} WHERE id = #{id}")
    public void update(yian yian);

    @Delete("delete from [yian] where id=#{id}")
    public void deleteById(long id);
}
